[quartz] find_toplevel_under_pointer should not return _gdk_root
authorJohn Ralls <jralls@ceridwen.us>
Fri, 22 Jul 2022 17:54:27 +0000 (10:54 -0700)
committerJohn Ralls <jralls@ceridwen.us>
Mon, 22 Aug 2022 15:58:08 +0000 (08:58 -0700)
The macOS WM has no root window. We fake one with a 1x1 window at the
origin that has no associated NSWindow. If the pointer is not on a
realized GdkWindow the hierarchical search will place it in the root
window even if it's nowhere near it. That's not valid, but returning it
from find_toplevel_under_pointer prevents Gdk from discovering when the
pointer is really over a GdkWindow. Return NULL instead so that the window
discovery is re-performed.

gdk/quartz/gdkevents-quartz.c

index 3cfc93e19df21c671d3f25a21c375941fe1c0677..f94fd978a0b35e21d15185b785fce8006f66994f 100644 (file)
@@ -659,15 +659,11 @@ find_toplevel_under_pointer (GdkDisplay *display,
 
     }
 
-  if (toplevel == NULL)
-    return NULL;
-
-  /*
-   * Root window type does not need translation, but also does not have
-   * an associated NSWindow and therefore can't translate screen points
+  /* If the stored toplevel is NULL or _gdk_root it's not useful,
+   * return NULL to regenerate.
    */
-  if (toplevel == _gdk_root)
-    return toplevel;
+  if (toplevel == NULL || toplevel == _gdk_root )
+    return NULL;
 
   get_window_point_from_screen_point (toplevel, screen_point, x, y);
   /* If the coordinates are out of window bounds, this toplevel is not